<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/8/14
 * Time: 17:39
 */
namespace App\Http\Controllers\Api\V1_0_0;

use App\Services\BankCardService;
use App\Services\CreditCardService;
use Illuminate\Http\Request;

class BankCardController extends BaseController
{
    protected $bankCardService;

    public function __construct(BankCardService $bankCardService)
    {
        parent::__construct();
        $this->bankCardService = $bankCardService;
    }

    /**
     * 储蓄卡列表
     * @return \Illuminate\Http\JsonResponse
     */
    public function bankCardList()
    {
        return $this->bankCardService->bankCardList($this->user['user_id']);
    }

    /**
     * 解绑储蓄卡
     * @param Request $request
     * @param CreditCardService $creditCardService
     * @return \Illuminate\Http\JsonResponse
     */
    public function unbindBankCard(Request $request)
    {
        if (empty($request->id)) {
            return $this->responseJson(422);
        }
        return $this->bankCardService->unbindBankCard($request->id, $this->user['user_id']);
    }

    /**
     * 默认储蓄卡设置
     */
    public function defaultBankCard(Request $request)
    {
        if (empty($request->id)) {
            return $this->responseJson(422);
        }
        return $this->bankCardService->defaultBankCard($request->id, $this->user['user_id']);
    }

}